package wiz.client.ui.viewimpl;

import wiz.client.activities.entrypoint.EntryPointView;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasEnabled;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class EntryPointViewImpl extends Composite  implements EntryPointView {

	private static EntryPointViewImplUiBinder uiBinder = GWT.create(EntryPointViewImplUiBinder.class);

	interface EntryPointViewImplUiBinder extends UiBinder<Widget, EntryPointViewImpl> {
	}

	public EntryPointViewImpl() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	
	@UiField
	VerticalPanel fPlayerListParent;
	
	@UiField
	Button fSelectPlayersButton;

	@UiField
	Button fStartGameButton;	
	
	@Override
	public HasClickHandlers getSelectPlayersClickHandlers() {
		return fSelectPlayersButton;
	}
	
	@Override
	public HasEnabled getStartGameButtonEnabled() {
		return fStartGameButton;
	}
	
	@Override
	public HasClickHandlers getStartGameButtonClickHandlers() {
		return fStartGameButton;
	}

	@Override
	public HasText[] addDisplayForPlayers(int numPlayers) {
		fPlayerListParent.clear();
		HasText toReturn[] = new HasText[numPlayers];
		for(int i = 0; i < numPlayers; i++){
			Label l = new Label();
			if(i % 2 == 1){
				l.setStyleName("cellTableOddRow", true);
			}
			fPlayerListParent.add(l);
			toReturn[i] = l;
		}
		return toReturn;
	}

}
